import { Pipe, PipeTransform } from '@angular/core';
import { formatCurrency, getCurrencySymbol } from '@angular/common';

/**
 * 人民币格式化
 */
@Pipe({
	name: 'rmb',
})
export class CurrencyRmbPipe implements PipeTransform {
	transform(
		value: number,
		currencyCode = 'CNY',
		digitsInfo = '3.2-2',
		locale = 'zh',
	): string | null {
		return formatCurrency(
			value,
			locale,
			getCurrencySymbol(currencyCode, 'wide'),
			currencyCode,
			digitsInfo,
		);
	}
}